package com.carl;

import com.carl.component.MessageComponent;
import com.carl.service.MessageService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ApplicationMain {

    public static void main(String[] args){
        String contextString = "applicationContext.xml" ;
        ApplicationContext context = new ClassPathXmlApplicationContext(contextString);
        System.out.println(" $$ context : " + context);

        String serviceString = "messageService";
        MessageService messageService = (MessageService) context.getBean(serviceString);
        System.out.println(messageService.getMessage());

        String componentString = "messageComponent";
        MessageComponent messageComponent = (MessageComponent) context.getBean(componentString);
        messageComponent.printMessage();

        System.out.println("%%%%%% component to true bean by service %%%%%%%%%%%");
        MessageComponent component = new MessageComponent(messageService);
        component.printMessage();
    }

}
